<?php
/**
 * Created by PhpStorm.
 * User: ysw
 * Date: 2020/6/20
 * Time: 10:40
 */

namespace app\api\service;

use think\Exception;
use think\Request;
use app\api\model\ErrorLogModel;

class ErrorLogService
{
    /**
     * 数据错误记录
     * @param $content
     * @return bool
     * @throws Exception
     */
    public function errorLog($content,$code){
        $ip = Request::instance()->ip();
        $arr = [
            'content'      => $content,
            'code'         => $code,
            'ip'           => $ip,
            'ipaddr'       => get_ip_area($ip),
        ];

        ErrorLogModel::getInstance()->allowfield(true)->isUpdate(false)->save($arr);
        return true;
    }
}